Repository navigation
667-deleteAll outbox 스케줄러 추가 - #668
Hidden character warning
Conversation
Walkthrough이 PR은 아웃박스 데이터를 정기적으로 삭제하기 위한 기능을 구현합니다. 삭제 포트 계약을 정의하고 어댑터에서 구현한 후, 매일 자정 직전(23:59)에 실행되는 스케줄된 작업으로 통합합니다. Changes아웃박스 삭제 기능 추가
🎯 2 (Simple) | ⏱️ ~10 minutesPossibly related PRs
Suggested labels
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@src/main/kotlin/dsm/pick2024/infrastructure/schedule/ScheduleService.kt`:
- Around line 89-92: The scheduled cleanOutbox() currently calls
deleteOutboxPort.deleteAll(), which risks removing unpublished/undelivered
events; change it to delete only events that are published and older than a
retention cutoff (e.g. compute cutoff =
LocalDateTime.now(ZoneId.of("Asia/Seoul")).minusDays(retentionDays)) and call a
new port method such as deletePublishedBefore(cutoff) (or add a
filterPublishedAndBefore(cutoff) to DeleteOutboxPort); update the
ScheduleService.cleanOutbox() to compute the cutoff and call that port method,
and implement the corresponding adapter/query to delete only records where
published=true (or publishedAt != null) AND publishedAt < cutoff.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: 0cac9717-5971-438a-a578-421fa146974f
📒 Files selected for processing (4)
src/main/kotlin/dsm/pick2024/domain/outbox/persistence/OutboxAdapter.ktsrc/main/kotlin/dsm/pick2024/domain/outbox/port/out/DeleteOutboxPort.ktsrc/main/kotlin/dsm/pick2024/domain/outbox/port/out/OutboxPort.ktsrc/main/kotlin/dsm/pick2024/infrastructure/schedule/ScheduleService.kt
| @Scheduled(cron = "0 59 23 * * ?", zone = "Asia/Seoul") | ||
| fun cleanOutbox() { | ||
| deleteOutboxPort.deleteAll() | ||
| } |
There was a problem hiding this comment.
전체 삭제 스케줄은 미처리 outbox 이벤트 유실 위험이 큽니다.
Line 91에서 매일 deleteAll()을 호출하면 아직 발행되지 않은 레코드까지 제거될 수 있습니다. 정리 대상은 최소한 발행 완료 + 보관기간 경과 조건으로 제한해야 합니다.
수정 방향 예시
`@Scheduled`(cron = "0 59 23 * * ?", zone = "Asia/Seoul")
fun cleanOutbox() {
- deleteOutboxPort.deleteAll()
+ deleteOutboxPort.deletePublishedBefore(
+ cutoff = LocalDateTime.now(ZoneId.of("Asia/Seoul")).minusDays(1)
+ )
}// 포트/어댑터 측 추가 예시 (선택)
interface DeleteOutboxPort {
fun deletePublishedBefore(cutoff: LocalDateTime): Long
}🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@src/main/kotlin/dsm/pick2024/infrastructure/schedule/ScheduleService.kt`
around lines 89 - 92, The scheduled cleanOutbox() currently calls
deleteOutboxPort.deleteAll(), which risks removing unpublished/undelivered
events; change it to delete only events that are published and older than a
retention cutoff (e.g. compute cutoff =
LocalDateTime.now(ZoneId.of("Asia/Seoul")).minusDays(retentionDays)) and call a
new port method such as deletePublishedBefore(cutoff) (or add a
filterPublishedAndBefore(cutoff) to DeleteOutboxPort); update the
ScheduleService.cleanOutbox() to compute the cutoff and call that port method,
and implement the corresponding adapter/query to delete only records where
published=true (or publishedAt != null) AND publishedAt < cutoff.
There was a problem hiding this comment.
해당 스케줄은 서비스 정책을 고려한 의도적인 동작입니다. 서비스는 20:30 이후에는 신규 이벤트가 생성되지 않으며, 날짜가 지난 이벤트가 뒤늦게 전송될 경우 오히려 사용자 혼선을 유발할 가능성이 더 크다고 판단했습니다.
따라서 outbox 데이터는 매일 종료 시점에 전체 정리하도록 구현했으며, 미전송 이벤트가 일부 제거될 가능성은 서비스 정책상 허용 가능한 trade-off로 보고 있습니다.
There was a problem hiding this comment.
@ByunDohwi, 설명 감사합니다. 서비스 정책상 20:30 이후 신규 이벤트가 생성되지 않으며, 날짜 경과 이벤트의 지연 전송이 오히려 사용자 혼선을 유발할 수 있다는 맥락을 이해했습니다. 해당 trade-off를 명시적으로 판단하신 것이므로 기존 구현 방식을 유지하는 것이 합리적입니다. 지적을 철회하겠습니다.
🐇 ~(=^‥^)/
✏️ Learnings added
Learnt from: ByunDohwi
Repo: DSM-PICK/PiCK_CORE_SERVER PR: 668
File: src/main/kotlin/dsm/pick2024/infrastructure/schedule/ScheduleService.kt:89-92
Timestamp: 2026-05-19T05:13:17.851Z
Learning: In `dsm/pick2024` (PiCK_CORE_SERVER), the `cleanOutbox()` scheduler in `src/main/kotlin/dsm/pick2024/infrastructure/schedule/ScheduleService.kt` intentionally calls `deleteOutboxPort.deleteAll()` (full deletion) at 23:59 every day. This is by design: the service generates no new outbox events after 20:30, and late delivery of stale events is considered more harmful (user confusion) than losing undelivered records. Deleting undelivered events at end-of-day is an explicitly accepted trade-off per service policy.
Note: Learnings are effective only in the context of similar code segments. To apply general coding guidelines, please configure review instructions. You can manage existing learnings in the app.
매일 23:59분 오늘 발행되었던 알림 이벤트를 outbox 테이블에서 삭제하는 스케줄러를 추가하였습니다.
Summary by CodeRabbit
릴리스 노트